<template>
	<view class="main">
	
		<view class="listV" @click="goDetail(item.id)" v-for="item in list">
			<ul class="listUl">
			   <li>
					<view class="one">
						<image src="https://recruit-oss.oss-cn-beijing.aliyuncs.com/recruit/img/v3/yiZ.png" mode=""></image>
						<view class="">{{item.name}}</view>
					</view>
					<view class="two">
						
						<image src="https://recruit-oss.oss-cn-beijing.aliyuncs.com/recruit/img/v3/dz.png" mode=""></image>
						<view class="text2">{{item.address}}</view>
					</view>
					<view class="two">
						
						<image src="https://recruit-oss.oss-cn-beijing.aliyuncs.com/recruit/img/lg/tel.png" mode=""></image>
						<view class="text2">{{item.tell}}</view>
					</view>
					
					<view class="three">
						<view class="zp">招聘信息:<text class="text1">{{item.job_count}}条</text></view>
						<view class="qz">求职信息:<text class="text1">{{item.worker_count}}条</text></view>
					</view>
					
				
				</li>
				<li>
					<image src="https://recruit-oss.oss-cn-beijing.aliyuncs.com/recruit/img/v3/xyb.png" mode=""></image>
				</li>
			</ul>
		</view>
		
		
		
		<u-loadmore
		  v-if="list.length != 0"
		  :status="status"
		  @loadmore="loadmore"
		></u-loadmore>
		

	</view>
</template>

<script>
	import api from '../../../../api/routes.js'
	export default{
		data(){
			return{
				"page":1, //页码
				"limit":30, //取多少条
				"lgt":"", //当前用户经度
				"lat":"" ,//当前用户纬度	
				list:[],
				status: "loadmore",
				load: false,
				total:0,
			}
		},
		onLoad() {
			this.getStationList();
		},
		// 下拉刷新
		onReachBottom() {
			  console.log(this.status ,88888888)
		  //页面抵达底部后，如果此时的status状态是加载更多，那就调用loadmore方法
		  if (this.status === "loadmore") {
		    this.loadmore();
		  }
		},
		methods:{
		goDetail(id){
			uni.navigateTo({
				url: '/package/pages/searchJob/other/stationDetailsPage?lbId='+id,
			});
		},
		loadmore() {
		  // 每次出发该方法，都要使页数加一
		  this.page++;
		  // 页数加一后，在调用getStationList方法，获取下一页的数据
		  this.getStationList();
		},
		// 判断是否还有更多数据
		ismore() {
		  console.warn(this.total, "====", this.list.length);
		  // 判断当数据总数等于数据列表的长度时，此时已经获取到全部数据，没有更多了，将加载状态改为nomore
		  if (this.total === this.list.length) {
		    this.status = "nomore";
		    // 否则，将状态改为loadmore，仍然还有数据
		  } else {
		    this.status = "loadmore";
		  }
		},
		getStationList(){
			if (this.load) {
			  return;
			}
			this.load = true;
			// 请求数据时，状态改为加载中状态
			this.status = "loading";
			// 获取当前地址
			let that =this;
			wx.getLocation({
			 type: 'wgs84',
			 success (re) {		   
				that.$myRequest({
					url: api.nearbyStation,
					method: "POST",
					data:{
						"page":1, //页码
						"limit":30, //取多少条
						"lgt":re.longitude, //当前用户经度
						"lat":re.latitude ,//当前用户纬度
					},
				}).then(res=>{
					// 请求完以后，将load改为false，方便下一次发送请求
					that.load = false;
					res  =  res.data;
				 
					if(res.code==0){
						that.total = res.page.totalCount;
						if(res.page.list.length>0){
							that.list = that.list.concat(res.page.list);
						}
						 console.log("----")
						 console.log(that.list)
						that.ismore();
						
					}else{
						return uni.showToast({
						  title: res.msg,
						  icon: "none",
						});
						 that.status = "nomore";
					}
					
				})
			 }
			})
			
				
			}
		}
	}
</script>

<style lang="scss" scoped>
	.main{
		background: #FAFAFA;
		
	}
		.listV{
		height: 130px;
		background:#FDFDFD ;
		// border: 1px solid gray;
		margin: 6px 10px 10px 10px;
		box-shadow: 0px 0px 2px 2px #f0efef;
		border-radius: 10px;
		.tell{
			line-height: 26px;
			margin-top: 8px;
			margin:0 0 0 6px;
		}
		
		.listUl{
			display: flex;
			height: 100%;
			color: black;
			// li:nth-child(1){
			// 	width: 24%;
			// 	display: flex;
			// 	align-items: center;
				
			// 	image{
			// 		width: 100%;
			// 		height: 75%;
			// 	}
			// }
			li:nth-child(1){
				// border: 1px solid green;
				width: 90%;
				padding-left: 8px;
				.one{
					display: flex;
					line-height: 30px;
					align-items: center;
					font-weight: bold;
					font-size: 16px;
					margin-top: 10px;
					image{
						width: 24px;	
						height: 24px;
					}
				}
				.two{
					display: flex;					
					line-height: 30px;
					align-items: center;
					font-size: 14px;
					
					.text2{
						justify-content: space-between;
						overflow: hidden;
						white-space: nowrap;
						text-overflow: ellipsis;
						width: 90%;

					}
					
					
					image{
						width: 24px;
						height: 24px;
					}
				}
				// .two{
				// 	display: flex;
				// 	height: 40px;
				// 	font-size: 12px;
				// 	align-items: center;
				// 	image{
				// 		width: 30px;
				// 		height: 20px;
				// 	}
				// }
				.three{
					display: flex;
					margin-left: 6px;
					line-height: 30px;
					.zp{
						width: 44%;
						font-weight: bold;
					}
					.qz{
						width: 44%;
						font-weight: bold;
					}
					.text1{
						color: gray;
						font-weight: normal;
					}
				}
				
			}
			li:nth-child(2){
				width: 10%;
				// border: 1px solid red;
				display: flex;
				align-items: center;
				image{
					width: 24px;
					height: 24px;
				}
			}
		}
		
	}
</style>